#ifndef MYTHREAD_H
#define MYTHREAD_H

#include <QThread>
#include "MyClient.h"
#include "QMessageBox"
#include <QSettings>

class MyThread:public QThread
{
public:
	MyThread(QObject * parent = 0){};


	void setClinet(MyClient* client){_myClient = client ;}
	void setBuffer(int s){_size = s;}
	void setCount(int c){_count = c;}
	void setWaitTime(int ms){_watiTime = ms;}

	void run()
	{
		QSettings setting("config.ini", QSettings::IniFormat);


		int recCount = setting.value("PacketCount/Count").toInt();

		int count=0;
		char* buffer = (char*)malloc(_size);
		for(int i=0;i<_size;++i)
			memcpy(buffer+i,"1",1);

		while(count<recCount)
		{
			_myClient->WriteData(buffer,_size);
			++count;
			msleep(_watiTime);
		}
		QMessageBox::information(NULL, "INFOR", "set packet finish!");
	}
public:
	MyClient* _myClient;
	int _size;
	int _count;
	int _watiTime;
};
#endif//MYTHREAD_H